package cn.itcast.zt.example.immutable;

import cn.itcast.zt.annotation.ThreadSafe;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;

import java.util.Collections;
import java.util.Map;

/**
 * 不可改变对象
 * create by zhangtian on 2018/4/8
 */
@Slf4j
@ThreadSafe
public class ImmutableExample1 {
    private static Map<Integer, Integer> map = Maps.newHashMap() ;

    static{
        map.put(1, 2) ;
        map.put(3, 4) ;
        map.put(5, 6) ;
        Collections.unmodifiableMap(map) ;
    }

    public static void main(String[] args) {
        map.put(1, 3) ;
        map.put(7, 8) ;
        log.info("{}", map.get(7));
    }
}
